import { RteCommandProp } from 'editor/command/declate'
import ButtonMenu from './button/button'
import DelimiterMenu from './delimiter/delimiter'
import DroplistMenu from './droplist/droplist'

export enum MenuType {
  BUTTON = 'button',
  DROPLIST = 'droplist',
  SELECTION = 'selection',
  DELIMITER = 'delimiter',
}

export interface ButtonMenuConfig {
  type: MenuType.BUTTON
  command: RteCommandProp
}

/**
 * [command, label][]
 */
export type DroplistMenuConfigOptions = [RteCommandProp, string][]

export interface DroplistMenuConfig {
  type: MenuType.DROPLIST
  options: DroplistMenuConfigOptions
}

export interface SelectionMenuConfig {
  type: MenuType.SELECTION
  command: RteCommandProp
  options: string[]
  icon?: boolean
}

interface DelimiterMenuConfig {
  type: MenuType.DELIMITER
}

export type MenuConfig = ButtonMenuConfig | DroplistMenuConfig | SelectionMenuConfig | DelimiterMenuConfig

export type MenuInstance = ButtonMenu | DroplistMenu | DelimiterMenu
